package com.memeuxe.awtrix.job;

import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.memeuxe.awtrix.base.lang.Const;
import com.memeuxe.awtrix.entity.Command;
import com.memeuxe.awtrix.util.CommandCache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.*;

@Component
@Slf4j
public class CommandJob {
    @Scheduled(cron = "0 * * * * ? ")
    public void filterCommand(){
        log.info("filterCommand run");
        Boolean inCron;
        Date now = new Date();
        for(Command command : CommandCache.commandList){
            if(command.getCronE().isSatisfiedBy(now)){
                //当前时间符合cron
                log.info("添加{}到队列", command);
                CommandCache.commandQueue.add(command);
            }
        }
    }
}
